//
//  WYTGreetingView.m
//  Diary
//
//  Created by lanou3g on 15/10/27.
//  Copyright © 2015年 王艺拓. All rights reserved.
//

#import "WYTGreetingView.h"
#import "WYTDevicesTool.h"

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kCoverImageViewHeight kScreenHeight / 3
#define kHeadSculptureSide [UIScreen mainScreen].bounds.size.width / 3.5
#define kUserLabelWidth kScreenWidth / 1.5
#define ktoShellButtonSide kScreenWidth / 16
#define kNoteTextViewWidth kScreenWidth * 0.8
#define kNoteTextViewHeight kScreenHeight * 0.145
#define kToDiaryButtonWidth kNoteTextViewWidth / 3.1
#define kToDiaryButtonHeight kToDiaryButtonWidth * 0.4
#define kFinishButtonSide kNoteTextViewHeight / 3
//#define kTimeLineViewHeight 3
//#define kTimeLineButtonSide 30

@interface WYTGreetingView ()

@property (nonatomic, strong)UIView *blackMaskView;
@property (nonatomic, assign)NSInteger userLabelFontSize;

@end

@implementation WYTGreetingView

- (instancetype)init{
    self = [super init];
    if (self) {
        [self setUps];
    }
    return self;
}

- (void)setUps{
    [self setUpDevices];
    [self setUpScene];
}

- (void)setUpDevices{
    if ([WYTDevicesTool iPhone6Plus_iPhone6sPlus]) {
        self.userLabelFontSize = 16;
    }else if ([WYTDevicesTool iPhone6_iPhone6s]){
        self.userLabelFontSize = 16;
    }else if([WYTDevicesTool iPhone320_DEVICES]){
        self.userLabelFontSize = 14;
    }
}

- (void)setUpScene{
    self.coverImageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kCoverImageViewHeight)];
    self.coverImageView.backgroundColor = [UIColor redColor];
    self.coverImageView.image = [UIImage imageNamed:@"coverViewBackGround"];
    [self addSubview:self.coverImageView];
    
    self.blackMaskView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.coverImageView.frame), kCoverImageViewHeight)];
    self.blackMaskView.backgroundColor = [UIColor blackColor];
    self.blackMaskView.alpha = 0.5;
    [self addSubview:self.blackMaskView];
    
    self.headSculpture = [[UIButton alloc]initWithFrame:CGRectMake((kScreenWidth - kHeadSculptureSide) / 2, kCoverImageViewHeight * 0.15, kHeadSculptureSide, kHeadSculptureSide)];
    self.headSculpture.backgroundColor = [UIColor orangeColor];
    self.headSculpture.layer.masksToBounds = YES;
    self.headSculpture.layer.cornerRadius = kHeadSculptureSide / 2;
    [self.headSculpture setImage:[UIImage imageNamed:@"userSculpture"] forState:UIControlStateNormal];
    [self addSubview:self.headSculpture];
    
    self.userStateTF = [[UITextField alloc]initWithFrame:CGRectMake((kScreenWidth - kUserLabelWidth) / 2, CGRectGetMaxY(self.headSculpture.frame) * 1.05, kUserLabelWidth, kCoverImageViewHeight / 5)];
    self.userStateTF.textColor = [UIColor whiteColor];
    self.userStateTF.textAlignment = NSTextAlignmentCenter;
    self.userStateTF.text = @"在这里可以编辑心情状态";
    self.userStateTF.font = [UIFont boldSystemFontOfSize:self.userLabelFontSize];
    [self addSubview:self.userStateTF];
    
    self.toShellButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.toShellButton.frame = CGRectMake(kScreenWidth * 0.9, kCoverImageViewHeight * 0.8, ktoShellButtonSide, ktoShellButtonSide);
    [self.toShellButton setImage:[UIImage imageNamed:@"toShellButtonImage"] forState:UIControlStateNormal];
    self.toShellButton.alpha = 0.8;
    [self addSubview:self.toShellButton];
    
    /*
     self.timeLineView = [[UIView alloc]init];
     self.timeLineView.frame = CGRectMake(0, kCoverImageViewHeight - kTimeLineViewHeight, kScreenWidth, kTimeLineViewHeight);
     self.timeLineView.backgroundColor = [UIColor orangeColor];
     [self.view addSubview:self.timeLineView];
     
     self.timeLineButton = [UIButton buttonWithType:UIButtonTypeCustom];
     self.timeLineButton.frame = CGRectMake(0, - (kTimeLineButtonSide - kTimeLineViewHeight) / 2, kTimeLineButtonSide, kTimeLineButtonSide);
     self.timeLineButton.backgroundColor = [UIColor blueColor];
     [self.timeLineButton setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
     self.timeLineButton.layer.masksToBounds = YES;
     self.timeLineButton.layer.cornerRadius = kTimeLineButtonSide / 2;
     [self.timeLineView addSubview:self.timeLineButton];
     */
    
    self.timeLineSlider = [[UISlider alloc]initWithFrame:CGRectMake(0, kCoverImageViewHeight, kScreenWidth, 1)];
    self.timeLineSlider.maximumTrackTintColor = [UIColor orangeColor];
    self.timeLineSlider.minimumTrackTintColor = [UIColor orangeColor];
    [self addSubview:self.timeLineSlider];
    
    CGFloat diaryScrollViewHeight;
    if ([WYTDevicesTool iPhone4_iPhone4s]) {
        diaryScrollViewHeight = kScreenWidth * 0.6;
    }else{
        diaryScrollViewHeight = kScreenWidth * 0.7;
    }
    self.diaryScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, kScreenHeight * 0.38, kScreenWidth, diaryScrollViewHeight)];
    self.diaryScrollView.backgroundColor = [UIColor whiteColor];
    self.diaryScrollView.contentSize = CGSizeMake(kScreenWidth * 10, 1);
    [self addSubview:self.diaryScrollView];
    
    CGFloat divViewWidth = kScreenWidth * 0.8;
    UIView *divView = [[UIView alloc]initWithFrame:CGRectMake((kScreenWidth - divViewWidth) / 2, CGRectGetMaxY(self.diaryScrollView.frame) + 1, divViewWidth, 1)];
    divView.backgroundColor = [UIColor grayColor];
    [self addSubview:divView];
    
    self.noteTextView = [[UITextView alloc]init];
    self.noteTextView.backgroundColor = [UIColor whiteColor];
    NSTextContainer *noteContainer = [[NSTextContainer alloc]initWithSize:CGSizeMake(self.noteTextView.frame.size.width, CGFLOAT_MAX)];
    self.noteTextView = [[UITextView alloc]initWithFrame:CGRectMake((kScreenWidth - kNoteTextViewWidth) / 2, kScreenHeight * 0.815, kNoteTextViewWidth, kNoteTextViewHeight) textContainer:noteContainer];
    self.noteTextView.backgroundColor = [UIColor whiteColor];
    self.noteTextView.textAlignment = NSTextAlignmentJustified;
    self.noteTextView.returnKeyType = UIReturnKeyDone;
    [self addSubview:self.noteTextView];
    
    self.toDiaryButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.toDiaryButton.frame = CGRectMake((kScreenWidth - kToDiaryButtonWidth) / 2, CGRectGetMaxY(self.noteTextView.frame) - kToDiaryButtonHeight / 2, kToDiaryButtonWidth, kToDiaryButtonHeight);
    self.toDiaryButton.backgroundColor = [UIColor orangeColor];
    self.toDiaryButton.alpha = 0.9;
    CGFloat toDiaryButtonTitleFontSize = 19;
    if ([WYTDevicesTool iPhone320_DEVICES]) {
        toDiaryButtonTitleFontSize = 16;
    }
    [self.toDiaryButton setTitle:@"写日记" forState:UIControlStateNormal];
    self.toDiaryButton.titleLabel.font = [UIFont boldSystemFontOfSize:toDiaryButtonTitleFontSize];
    [self addSubview:self.toDiaryButton];
    
    self.finishButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.finishButton.frame = CGRectMake(CGRectGetMaxX(self.noteTextView.frame) - kFinishButtonSide / 2, CGRectGetMaxY(self.noteTextView.frame) - kNoteTextViewHeight / 2 - kFinishButtonSide / 2, kFinishButtonSide, kFinishButtonSide);
    self.finishButton.backgroundColor = [UIColor orangeColor];
    self.finishButton.layer.masksToBounds = YES;
    self.finishButton.layer.cornerRadius = kFinishButtonSide / 2;
    [self addSubview:self.finishButton];
}

@end
